package com.ggb.reactive.repository

import com.ggb.reactive.domain.entity.ShoppingCart
import org.springframework.data.r2dbc.repository.Modifying
import org.springframework.data.r2dbc.repository.Query
import org.springframework.data.repository.reactive.ReactiveCrudRepository
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono

interface ShoppingCartRepository: ReactiveCrudRepository<ShoppingCart, Long> {
    @Modifying
    @Query("UPDATE shopping_cart SET number = :number WHERE id = :id")
    fun updateNumberById(number: Int, id: Long): Mono<Long>
    fun deleteAllByUserId(userId: Long):Mono<Void>
    fun findAllByUserId(userId: Long): Flux<ShoppingCart>
}